/**
 * Description:一些注释<br/>
 * CreateTime:2019-04-17<br/>
 * Creater: yangpengfei360@126.com <br/>
 * @author yangpengfei
 */
package cn.cnsy123.bookwebsiteserver.controller.library;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.cnsy123.bookwebsiteserver.entity.SysBookLibraryInfo;
import cn.cnsy123.bookwebsiteserver.service.library.SysLibraryInfoService;
import cn.cnsy123.bookwebsiteserver.vo.layui.CommonResult;

/**
 * Description:一些注释<br/>
 * CreateTime:2019-04-17<br/>
 * Creater: yangpengfei360@126.com <br/>
 * @author yangpengfei
 */
@Controller
@RequestMapping(value = "library")
public class SysLibraryInfoController {
    @Autowired
    private SysLibraryInfoService sysLibraryInfoService;

    @GetMapping(value = "bookLibrary")
    public ModelAndView bookLibraryInfoPage() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("bookLibraryInfo");
        modelAndView.setStatus(HttpStatus.OK);
        return modelAndView;
    }
    @GetMapping(value = "managerList")
    @ResponseBody
    public CommonResult<Object> findLibraryManagerList(){
        CommonResult<Object> result = new CommonResult<Object>();
        try {
            return sysLibraryInfoService.findLibraryManagerList();
        }catch(Exception e) {
            result.setCode(1);
            result.setMsg("获取馆长信息失败");
        }
        return result;
    }
    
    @GetMapping(value = "standloneItem")
    @ResponseBody
    public CommonResult<Object> findLibraryInfo(){
        CommonResult<Object> result = new CommonResult<Object>();
        try {
            return sysLibraryInfoService.findLibraryInfo();
        }catch(Exception e) {
            result.setCode(1);
            result.setMsg("获取图书馆信息失败");
        }
        return result;
    }
    
    
    @PostMapping(value = "save")
    @ResponseBody
    public CommonResult<Object> saveLibraryInfo(SysBookLibraryInfo sysBookLibraryInfo){
        CommonResult<Object> result = new CommonResult<Object>();
        try {
            return sysLibraryInfoService.saveLibraryInfo(sysBookLibraryInfo);
        }catch(Exception e) {
            result.setCode(1);
            result.setMsg("获取图书馆信息失败");
        }
        return result;
    }
    
}
